import Vue from 'vue'
import App from './App.vue'
//按需引入

// import '../src/plugins/element'

//全局引入
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)

import 'font-awesome/css/font-awesome.min.css'
import axios from 'axios'
import router from '../src/router/idnex'
import service from '@/service'

import echarts from 'echarts'
Vue.config.productionTip = false
// Vue.prototype.axios = axios
Vue.prototype.service = service
Vue.prototype.$echarts = echarts

// 路由导航守卫
router.beforeEach((to, from, next) => {
  if (!localStorage.getItem('username')) {
    if (to.path !== '/login') {
      next('/login')
    } else next()
  }
  next()
})
new Vue({
  router,
  render: (h) => h(App),
}).$mount('#app')
